package top.mccat.common.core.controller.bk;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import top.mccat.common.annotation.Log;
import top.mccat.common.core.controller.BaseController;
import top.mccat.common.core.domain.AjaxResult;
import top.mccat.common.core.domain.bk.BkArrears;
import top.mccat.common.enums.BusinessType;
import top.mccat.common.service.IBkArrearsService;
import top.mccat.common.utils.poi.ExcelUtil;
import top.mccat.common.core.page.TableDataInfo;

/**
 * arrearsController
 * 
 * @author ruoyi
 * @date 2023-01-23
 */
@RestController
@RequestMapping("/bk/arrears")
public class BkArrearsController extends BaseController
{
    @Autowired
    private IBkArrearsService bkArrearsService;

    /**
     * 查询arrears列表
     */
    @PreAuthorize("@ss.hasPermi('bk:arrears:list')")
    @GetMapping("/list")
    public TableDataInfo list(BkArrears bkArrears)
    {
        startPage();
        List<BkArrears> list = bkArrearsService.selectBkArrearsList(bkArrears);
        return getDataTable(list);
    }

    /**
     * 导出arrears列表
     */
    @PreAuthorize("@ss.hasPermi('bk:arrears:export')")
    @Log(title = "arrears", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BkArrears bkArrears)
    {
        List<BkArrears> list = bkArrearsService.selectBkArrearsList(bkArrears);
        ExcelUtil<BkArrears> util = new ExcelUtil<BkArrears>(BkArrears.class);
        util.exportExcel(response, list, "arrears数据");
    }

    /**
     * 获取arrears详细信息
     */
    @PreAuthorize("@ss.hasPermi('bk:arrears:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return AjaxResult.success(bkArrearsService.selectBkArrearsById(id));
    }

    /**
     * 新增arrears
     */
    @PreAuthorize("@ss.hasPermi('bk:arrears:add')")
    @Log(title = "arrears", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BkArrears bkArrears)
    {
        return toAjax(bkArrearsService.insertBkArrears(bkArrears));
    }

    /**
     * 修改arrears
     */
    @PreAuthorize("@ss.hasPermi('bk:arrears:edit')")
    @Log(title = "arrears", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BkArrears bkArrears)
    {
        return toAjax(bkArrearsService.updateBkArrears(bkArrears));
    }

    /**
     * 删除arrears
     */
    @PreAuthorize("@ss.hasPermi('bk:arrears:remove')")
    @Log(title = "arrears", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(bkArrearsService.deleteBkArrearsByIds(ids));
    }
}
